Blog

ColdBox Beta 2: Flex/AIR Integration

Luis Majano October 15, 2008

Spread the word

Luis Majano

October 15, 2008

Spread the word


Share your thoughts

Well, my secret project is out of the bag today. I have been working in embedding a remote proxy into ColdBox in order to enable remote applications like Flex and AIR to communicate with ColdBox and provide an event model for our model. If that makes sense!! Well, so what do we get? This feature lets you create an event driven model that can easily be called from any flex/air application. Not only that, but you can reinitialize the entire application, get settings, and yes, announce custom or core interceptions. You can create custom interceptor chains for your model that can be executed asynchronously when a user hits a save record button for example. The possibilities are endless. Not only that, but this enables you to actually create two front ends using the same reusable ColdBox and model code. The code is the same, you create event handlers, you interact with a request collection, with core and custom plugins, but you don't set views or layouts because the framework is now a remote framework for your model. So what do you do, well, return data, arrays, xml, value objects. Anything, right from withing the event handlers.

//Just return an array var myArray = ArrayNew(1); myArray[1] = "Hola"; myArray[2] = "Hello"; myArray[3] = "Bom Dia"; myArray[4] = "Ciao"; myArray[5] = getMyPlugin("date").getToday(); //Log my call getPlugin("logger").logEntry("information","My intro arrays called from flex."); return myArray; As you can see from my event above, my event is called "getIntroArrays", which uses a plugin to do some logging and return an array to flex. So simple, what is even better is the following: What is this? Well, the event context object now has a new method called: "isProxyRequest()" which let's you know that the ColdBox proxy is executing the event. With this you can run alternate code or eliminate presentation. WOW!! That simple!! What is even more impressive is that your coldboxproxy component is actually an inherited proxy. So you can override the proxy or customize it according to your needs. You can intercept proxy calls, create your own custom proxy methods and tap into the framework as you see fit!! You have the flexibility to do so. Here is a sample flex code setting up the RemoteObject Here is a sample of the call: /* GET TEST ARRAY */ public function handleArrayResults(event:ResultEvent):void{ aResult=event.result as Array; } public function getRemoteArray():void{ coldboxProxy.addEventListener("result",handleArrayResults); coldboxProxy.process({event:"ehFlex.getIntroArrays"}); } As you can see, you call the process method with the event you want to execute. If you would like to pass in a whole bunch of params then you do the following: var params:Object = new Object(); params.event = "ehFlex.getUsers"; params.user_id = txt_username.text; params.password = txt_password.text; coldboxProxy.process(params); And there you go, you send in the params and execute the event. Well, I hope this is a good teaser of what you will be getting in beta 2 of ColdBox 2.5.0. The requirements for having a Flex/Air enabled application are very minimal, just by simple returning results from your handlers and setting a hard coded AppMapping variable, so coldbox can parse your application. I will be posting much more on this topic as beta 2 time arises. Ohh by the way, the code is in SVN with a full Flex/ColdBox application. Enjoy!!

Add Your Comment

(7)

Oct 27, 2007 19:35:43 UTC

by Russ Johnson

Luis, this is fabulous! I love the idea of using existing model code in a ColdBox application for a Flex front end. This is great! I cant wait to start playing with this.

Oct 27, 2007 19:44:45 UTC

by Sana

I don’t have words to say thanks for such a great development toolkit you are offering. Its toooooo awesome man: you are really rocking! Anybody you dare to test new incredible features can download bleeding edge code from SVN: svn co http://ortus.svnrepository.com/svn/coldbox/coldbox/trunk or via https://secure.svnrepository.com/s_lmajano/coldbox/coldbox/trunk username: nightlybuild pass: nightlybuild Again thanks so much for these great features. You made the development so easy-peasy; so nobody would have excuse that coldbox does support RIA. I think coldbox is a must have a tool like cfeclipse

Oct 27, 2007 20:37:29 UTC

by Sean Corfield

I demo'd Blackstone (CFMX7) at Fusebox 2004 and showed a proxy for Fusebox that worked like this but I didn't recommend people did it because it really just forced the Flex/Fusebox communication to use a query string, albeit as a method call. However, it does appear to be a very appealing approach to a lot of people and that's why I started Edmund recently... Maybe I'll have another look at ColdBox now you've added this and see whether it's even worth me continuing with Edmund!

Oct 27, 2007 20:43:16 UTC

by Luis Majano

Hi Sean, The proxy works by method calling via a remote object or treating the proxy as a webservice. So you can call the different methods on it. The idea was to use the "onMissingMethod" approach, but since we still have to support cf7, the proxy is based on cf7 capabilities. However, the release will include also a cf8 proxy, which will be based on cf8's capabilties. I truly welcome your input, and check out the sample app. Maybe we can come up with more goodness for the proxy.

Oct 28, 2007 12:15:34 UTC

by Sami Hoa

Well done Luis. You keep pushing things to the limit. Keep it up!

Oct 30, 2007 21:38:51 UTC

by Rob Gonda

Ok, I give up. I've been trying to comment for a couple of days and it fails silently. Follow this link to read my comments: http://www.robgonda.com/blog/index.cfm/2007/10/30/ColdBox-Beta-2-FlexAIR-Integration-comments

Apr 18, 2008 02:18:19 UTC

by Andychou

Need 3 Flex engineers in New York City: 1. You have to be living in New York City for now. 2. Work part time or full time with us. 3. Good at Adobe Flex technology. 4. Please contact us for other requirement and details. Busycode Inc. is a top Adobe Flex shop who develops Flex/AIR applications for clients. For more info, please visit http://www.busycode.com

Recent Entries

TestBox Latest Updates and News!

TestBox Latest Updates and News!

We’re thrilled to have launched the new TestBox website and TestBox 6.0! If you haven’t had a chance to explore yet, visit TestBox to discover updated documentation, powerful resources, and features that make testing more efficient than ever.

Maria Jose Herrera
Maria Jose Herrera
November 21, 2024
Is Your ColdFusion Application Ready for the Future?

Is Your ColdFusion Application Ready for the Future?

In a rapidly evolving digital world, maintaining performance, security, and scalability for ColdFusion applications is more challenging than ever. Whether you're using Lucee or Adobe ColdFusion, legacy systems can become a bottleneck for growth, innovation, and user satisfaction. The need to future-proof your ColdFusion applications has never been more critical.

But where do you start?


The Hidden Costs of an Outdated ColdFusion Application

As you...

Cristobal Escobar
Cristobal Escobar
November 21, 2024
The Hidden Costs of In-House Database Management

The Hidden Costs of In-House Database Management

The Hidden Costs of In-House Database Management


Opting for in-house database management involves more than just a salary. Here are some often-overlooked costs associated with maintaining your own DBA team.



1. High Salaries and Benefits


Hiring skilled DBAs is expensive. According to industry reports, the average salary of a DBA in the U.S. can range from $85,000 to over $130,000 per year, depending on experience and expertise. When you add ...

Cristobal Escobar
Cristobal Escobar
November 20, 2024